print('Введите скобочную последовательность:')
st = input()
stack = []
flag = True
for i in st:
    if i == '(':
        stack.append(i)
    elif i == ')':
        if stack[-1] == '(':
            stack.pop()
        else:
            flag = False
    elif i == '[':
        stack.append(i)
    elif i == ']':
        if stack[-1] == '[':
            stack.pop()
        else:
            flag = False
    elif i == '{':
        stack.append(i)
    elif i == '}':
        if stack[-1] == '{':
            stack.pop()
        else:
            flag = False
    elif i == '<':
        stack.append(i)
    elif i == '>':
        if stack[-1] == '<':
            stack.pop()
        else:
            flag = False

if not stack and flag:
    print(True)
else:
    print(False)